import fromItem from '@/components/from-item/from-item.vue'
var maxNum = 6;
var sourceType = [
	['camera'],
	['camera', 'album']
];

export default {
	components: {
		fromItem,
	},
	data() {
		return {
			// 照片
			fPhotofileList: [],
			// 照片
			// 视频
			fSourcefileList: [],
			mapShow: false,
			loading: false,
			contentShow: false, //折叠
			isSrc: "@/static/down.png",
			fastImgLists: [],
			// 视频
			// 地图
			markers: [],
			// 地图
			totalData: {
				fId: "", //传fid表示修改 不传表示新增
				userId: "", //当前登录人id
				userName: "", //当前登录人姓名
				fCompanyid: "", //施工单位id 隐藏
				fCompanyname: "", //施工单位名称 隐藏
				fProjectid: "", //项目id 隐藏
				fProjectname: "", //项目名称 隐藏
				fChecktypenum: "", //0自检1外委
				fChecktype: "", //检测类型  施工自检,施工外委/监理抽检,监理外委
				fEntryledgerid: "", //材料进场编号id 隐藏
				fEntrynumber: "", //材料进场编号
				fMaterialtypeid: "", //材料进场材料种类id
				fSamplenostr: "", //取样编号
				fSampletype: "", //样品种类id 隐藏
				fSampletypename: "", //样品种类汉字
				fVarietyid: "",
				fSamplemodel: "", //样品编码
				fSamplespecs: "", //样品规格
				fSamplemessage: "", //样品描述
				fBusinessscopename: "", //取样标段
				fSamplename: "", //样品名称
				fDeputynum: "", //代表数量
				fSampleno: "", //生产批号  沥青标号  出厂编号
				fTesttype: "", //沥青种类  钢筋种类 混凝土种类  砂浆种类 钢筋种类
				fSampletestpiece: "", //试件编号
				fStrengthgrade: "", //品种等级 品种强度等级 强度等级
				fSpecimenage: "", //养护龄期  
				// SpecimenageList: [], //养护龄期--页面展示
				fSpecimensize: "", //试件尺寸  
				fProductiondate: "", //制件日期  生产日期
				fProductiondates: "", //制件日期  
				fBrand: " ", //牌号   
				fDiameter: "", //直径	  
				fManufacturer: "", //生产厂家
				fPlace: "", //产地
				fAddress: "", //取样地点
				fProjectlocation: "", //工程部位/用途
				fProjectlocationid: '', //工程部位/用途id
				fApproachdates: "", //进场日期
				fSampledates: "", //取样日期
				fSampleperson: "", //取样人
				fSamplepersonid: "", //取样人id
				fWitnessperson: "", //见证人
				fNote: "", //备注
				fLon: "", //经度
				fLat: "", //纬度
				recordfiles: [], //删除文件id集合
				fPhotofile: "", //取样现场照片id
				fSourcefile: "", //现场取样视频件id
				fSamplenum: "", //外加剂掺量
				fMixingmethod: "", //搅拌方式
				fWarecondition: "", //养护条件
				fTestlayer: "", //试验层位
				fGradationtype: "", //级配类型
				isSubmit: "0", //0 保存 1提交
			},


			userInfo: null,
			options: null, //上个页面传递过来的参数


			//显示隐藏
			// basic: 1, //根据试件类型展示不同内容
			formObjText_zj: null, //自检---根据样品种类展示不同内容
			fStrengthgradeText: null, //fStrengthgrade---对应文字
			fSamplenoText: null, //fSampleno---对应文字
			fTesttypeText: null, //fTesttype---对应文字
			fProductiondatesText: null, //fProductiondates---对应文字
			//显示隐藏
			isScanCode: false
		};
	},

	onReady() {},

	onLoad(options) {
		// console.log('options', options);
		var that = this;
		uni.getStorage({ //监督检查方式
			key: 'userInfo',
			success: function(res) {
				that.userInfo = JSON.parse(res.data);
			}
		});

		that.options = options;
		that.getDetailData(options.id);
		// || MP-WEIXIN || H5
		// #ifdef APP-PLUS

		// #endif
		// #ifdef H5

		// #endif

	},
	onShow() {

	},


	onUnload() {


	},

	methods: {
		getDetailData(id) {
			var that = this;
			var datas = {
				fId: id,
			}
			that.$http.getSampleWorkByFid(datas).then(res => {
				if (res.errcode == 0) {
					that.totalData = res.data.lrCheckSample;
					if (that.totalData.fChecktypenum == "0") {
						that.isScanCode = false;
						if (that.totalData.fSampletypename == "土") {
							that.formObjText_zj = 1;
						} else if (that.totalData.fSampletypename == "粗集料" || that.totalData.fSampletypename ==
							"细集料" || that.totalData.fSampletypename ==
							"岩石") {
							that.formObjText_zj = 2;
						} else if (that.totalData.fSampletypename == "矿粉") {
							that.formObjText_zj = 3;
						} else if (that.totalData.fSampletypename == "水泥") {
							that.formObjText_zj = 4;
							that.fStrengthgradeText = "品种强度等级";
							that.fSamplenoText = "出厂编号";
						} else if (that.totalData.fSampletypename == "水") {
							that.formObjText_zj = 5;
						} else if (that.totalData.fSampletypename == "外加剂") {
							that.formObjText_zj = 6;
							that.fProductiondatesText = "生产日期";
							that.fSamplenoText = "生产批号";
						} else if (that.totalData.fSampletypename == "石灰") {
							that.formObjText_zj = 7;
							that.fStrengthgradeText = "品种等级";
							that.fProductiondatesText = "生产日期";
						} else if (that.totalData.fSampletypename == "粉煤灰") {
							that.formObjText_zj = 8;
							that.fStrengthgradeText = "品种等级";
							that.fProductiondatesText = "生产日期";
						} else if (that.totalData.fSampletypename == "普通沥青") {
							that.formObjText_zj = 9;
							that.fSamplenoText = "沥青标号"
							that.fTesttypeText = "沥青种类";
							that.fProductiondatesText = "生产日期";
						} else if (that.totalData.fSampletypename == "钢筋原材"|| that.totalData.fSampletypename==
							"钢筋焊接" || that.totalData.fSampletypename == "钢筋机械连接") {
							that.formObjText_zj = 10;
							that.isScanCode = true;
							that.fSamplenoText = "批号"
							that.fTesttypeText = "钢筋种类";
						} else if (that.totalData.fSampletypename == "钢筋原材" || that.totalData.fSampletypename ==
							"钢筋机械连接" || that.totalData.fSampletypename ==
							"水泥混凝土抗弯拉" || that.totalData.fSampletypename == "水泥抗折抗压强度") {
							that.isScanCode = true;

						} else if (that.totalData.fSampletypename == "水泥混凝土拌合物") {
							that.formObjText_zj = 11;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "混凝土种类";
						} else if (that.totalData.fSampletypename == "硬化后水泥混凝土") {
							that.formObjText_zj = 12;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "混凝土种类";
							that.fProductiondatesText = "制件日期";
							that.isScanCode = true;
						} else if (that.totalData.fSampletypename == "水泥砂浆拌合物") {
							that.formObjText_zj = 13;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "砂浆种类";
						} else if (that.totalData.fSampletypename == "硬化后水泥砂浆") {
							that.formObjText_zj = 14;
							that.isScanCode = true;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "砂浆种类";
							that.fProductiondatesText = "制件日期";
						} else if (that.totalData.fSampletypename == "硬化后水泥净浆") {
							that.formObjText_zj = 15;
							that.isScanCode = true;
						} else if (that.totalData.fSampletypename == "沥青混合料") {
							that.formObjText_zj = 16;
							that.fTesttypeText = "沥青混合料类型";
						} else {
							that.formObjText_zj = 0;
						}
					}
					// if (that.totalData.fTesttype == "" || that.totalData.fTesttype == null) {
					// 	that.basic = 0;
					// } else if (that.totalData.fTesttype == "钢筋试件") {
					// 	that.basic = 2;
					// } else {
					// 	that.basic = 1;
					// }
					// 经纬度
					that.latitude = that.totalData.fLat;
					that.longitude = that.totalData.fLon;

					// 照片
					var photo = res.data.fPhotofileList;
					that.fPhotofileList = photo.map((item) => {
						return item.url

					});

					// 视频
					var video = res.data.fSourcefileList;
					video.map((item) => {
						var imgSrc = item.fFilePath;
						var src;

						if (imgSrc.indexOf("mp4") != -1 && imgSrc.indexOf("D:") != -
							1) {
							imgSrc = imgSrc.replace(/D:/, that.$htth.file)
							src = imgSrc.replace(/mp4/, "jpg")
						} else {
							src =
								"https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E8%A7%86%E9%A2%91%E5%9B%BE%E7%89%87&step_word=&hs=0&pn=43&spn=0&di=119790&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=2&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=-1&cs=3346960024%2C2036034045&os=4174661132%2C668644710&simid=0%2C0&adpicid=0&lpn=0&ln=1485&fr=&fmq=1626946136579_R&fm=result&ic=&s=undefined&hd=&latest=&copyright=&se=&sme=&tab=0&width=&height=&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fpic.vjshi.com%2F2017-02-23%2F812ed99eb35888901ff0e220bb05120c%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark%26refer%3Dhttp%3A%2F%2Fpic.vjshi.com%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1629538162%26t%3Df3acdf9335d81ccd4fbc9cdc305d8dc3&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3Be3fit_z%26e3Bv54AzdH3FowpviAzdH3Fl00cam_z%26e3Bip4s&gsm=&rpstart=0&rpnum=0&islist=&querylist=&nojc=undefined"
						}
						that.fastImgLists.push({
							filePath: item.url,
							id: item.fId,
							src: src,
							needload: false,
							type: 'video'
						})

					})

					var markers = []
					markers = markers.concat({
						iconPath: require("@/static/position.png"),
						latitude: that.latitude, //纬度
						longitude: that.longitude, //经度


					})
					that.markers = markers

					that.mapShow = true
					that.loading = true
					// this.fileList = res.data.fPhotofileList
					// this.stationfile = res.data.fSourcefileList
				} else {
					uni.showToast({
						title: "请求失败",
						icon: 'none',
						duration: 2000
					});
				}

			}, (err) => {
				uni.showToast({
					title: "接口报错",
					icon: 'none',
					duration: 2000
				});
			})
		},
		// 控制视频折叠面板
		changeContent() {
			// this.isSrc=""
			this.contentShow = !this.contentShow
		},
		getMakers() {
			if (this.latitude != "" && this.longitude != "") {
				var markers = []
				var that = this
				markers = markers.concat({
					iconPath: require("@/static/position.png"),
					latitude: that.latitude, //纬度
					longitude: that.longitude, //经度
				})
				that.markers = markers
			}
		},
		// 预览照片
		ViewImage(e) {
			uni.previewImage({
				urls: this.fPhotofileList,
				current: e.currentTarget.dataset.url
			});
		},
		// 视频
		interVideo(src) {
			// console.log(src)
			uni.navigateTo({
				url: '/pages/commonVideo/commonVideo?src=' + src
			});
		},


	}
}
